//$ null 与 undefined --------
const tmp1: null = null;
const tmp2: undefined = undefined;

const tmp3: string = null; // 仅在关闭 strictNullChecks 时成立，下同
const tmp4: string = undefined;


//$ void -------------
void function iife() {
  console.log("Invoked!");
}();


const voidVar1: void = undefined;

const voidVar2: void = null; // 需要关闭 strictNullChecks

// $---  数组的类型标注------
const arr1: string[] = [];

const arr2: Array<string> = [];


const arr3: string[] = ['lin', 'bu', 'du'];

console.log(arr3[599], "--");

// $元组（Tuple）----
const arr4: [string, string, string] = ['lin', 'bu', 'du'];

// console.log(arr4, arr4[599]); // 检查到报错
console.log(arr4, arr4[1])

const arr5: [string, number, boolean] = ['linbudu', 599, true];

const arr6: [string, number?, boolean?] = ['linbudu'];
// 下面这么写也可以
// const arr6: [string, number?, boolean?] = ['linbudu', , ,];

type TupleLength = typeof arr6.length; // 1 | 2 | 3

// const NumTest: TupleLength = Math.ceil(Math.random() * 3)  // 这个如何改呢？？
const NumTest: TupleLength = 3


// $ --TypeScript 4.0 中，有了具名元组
const arr7: [name: string, age: number, male?: boolean] = ['linbudu', 599];


const arrT1: string[] = [];
const [ele1, ele2, ...rest] = arrT1;

// 对于元组，隐式的越界访问也能够被揪出来给一个警告：
const arrT2: [string, number, boolean] = ['linbudu', 599, true];

// 长度为 "3" 的元组类型 "[string, number, boolean]" 在索引 "3" 处没有元素。
// const [nameT2, age, male, other] = arrT2;